Beautiful maps in R

maps
sf
osm
Author

Santiago Sotelo

Published

August 20, 2023

In this publication we will observe how to make maps in R. In the world of programmatic cartography, using software either ArcGis, QgGis, or in this case R, it is necessary to know concepts such as polygons, vectors, raster, CRS, among others. Each of them are important in the spatial representation of information. However, in this post we will see that with the help of the {rcityviews} package we can make maps without the need to delve into these concepts and with great aesthetic value.

The map

As a place to plot, I will choose Lima, my home city. Lima is a coastal city which is covered on the west by the “Sea of Grau”, which gives way to the Pacific Ocean. If we use coordinates, Lima is 12.07° to the South, and 77.05° to the West.

The {rcityviews} package allows us to customise the colours, the distance and even cartographic elements such as the North Arrow, the scale, the coordinates, etc. In this case, we will use the default colours together with the north arrow and the scale.

remotes::install_github("koenderks/rcityviews", dependencies = TRUE)
library(rcityviews)

p <- cityview(name = "Lima", zoom = 0.1, legend = TRUE)

ggplot2::ggsave(filename = "Lima map.png", plot = p, height = 500, width = 500, units = "mm", dpi = 100)

Map of Lima

This is how we can create our map with the relevant cartographic elements for orientation. Moreover, the programmatic colour composition of the map is quite nice, so much so that it could be printed out and used as a illustration.

Citation

BibTeX citation:
@online{sotelo2023,
  author = {Sotelo, Santiago},
  title = {Beautiful Maps in {R}},
  date = {2023-08-20},
  url = {https://santiagosotelo.com//posts/2023-08-20 mapping/en},
  langid = {en}
}
For attribution, please cite this work as:
Sotelo, Santiago. 2023. “Beautiful Maps in R.” August 20, 2023. https://santiagosotelo.com//posts/2023-08-20 mapping/en.